package vtt.android.dapanhc.activities;

import vtt.android.library.activities.VttBaseActionBarActivity;
import android.content.Context;
import android.content.pm.ActivityInfo;
import android.media.AudioManager;
import android.os.Bundle;
import android.view.KeyEvent;

public class BaseActivity extends VttBaseActionBarActivity {

	private AudioManager audio;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);

		initActionBar();

		audio = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
	}

	protected void initActionBar() {
		actionBar = getSupportActionBar();
		if (actionBar != null) {
			// actionBar.setBackgroundDrawable(getResources().getDrawable(R.drawable.background_repeat_dark));
		}
	}

	@Override
	public boolean onKeyDown(int keyCode, KeyEvent event) {
		switch (keyCode) {
		case KeyEvent.KEYCODE_VOLUME_UP:
			audio.adjustStreamVolume(AudioManager.STREAM_MUSIC, AudioManager.ADJUST_RAISE, AudioManager.FLAG_SHOW_UI);
			return true;
		case KeyEvent.KEYCODE_VOLUME_DOWN:
			audio.adjustStreamVolume(AudioManager.STREAM_MUSIC, AudioManager.ADJUST_LOWER, AudioManager.FLAG_SHOW_UI);
			return true;
		default:
			return super.onKeyDown(keyCode, event);
		}
	}
}
